export default <T extends (...args: any[]) => void>(fn: T, delay: number) => {
    let timer: NodeJS.Timeout;
    return function (...args: Parameters<T>) {
      timer && clearTimeout(timer);
      timer = setTimeout(() => {
        fn(...args);
      }, delay);
    };
  };
  